{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2016, OpenNebula Project, OpenNebula Systems                }}
{{!                                                                            }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may    }}
{{! not use this file except in compliance with the License. You may obtain    }}
{{! a copy of the License at                                                   }}
{{!                                                                            }}
{{! http://www.apache.org/licenses/LICENSE-2.0                                 }}
{{!                                                                            }}
{{! Unless required by applicable law or agreed to in writing, software        }}
{{! distributed under the License is distributed on an "AS IS" BASIS,          }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   }}
{{! See the License for the specific language governing permissions and        }}
{{! limitations under the License.                                             }}
{{! -------------------------------------------------------------------------- }}

<form>
  <h4>{{tr "Role"}} - {{role.name}}</h4>
  <div class='large-12 columns'>
    <table class='dataTable policies_table'>
      <thead>
        <tr>
          <th colspan='8'>{{tr "Information"}}</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td class='key_td'>{{tr "Shutdown action"}}</td>
          <td class='value_td'>{{valOrDefault role.shutdown_action "-"}}</td>
          <td class='key_td'>{{tr "Cooldown"}}</td>
          <td class='value_td'>{{valOrDefault role.cooldown "-"}}</td>
          <td class='key_td'>{{tr "Min VMs"}}</td>
          <td class='value_td'>{{valOrDefault role.min_vms "-"}}</td>
          <td class='key_td'>{{tr "Max VMs"}}</td>
          <td class='value_td'>{{valOrDefault role.max_vms "-"}}</td>
        </tr>
      </tbody>
    </table>
    <br>
  </div>
  {{#if servicePanel}}
  <fieldset>
    <legend>{{tr "Virtual Machines"}}</legend>
    <div id="role_vms_actions">
      <div class="action_blocks large-12 columns">
      </div>
    </div>
    <div class="large-12 columns">
      <br>
      <table id="datatable_vms_{{panelId}}_{{role.name}}" class="dataTable hover ">
        <thead>
          <tr>
            <th></th>
            <th></th>
            <th class="check">
              <input type="checkbox" class="check_all" value=""></input>
            </th>
            {{#each vmsTableColumns}}
            <th>{{this}}</th>
            {{/each}}
          </tr>
        </thead>
        <tbody>
          {{#each vms}}
          <tr>
            {{#each this}}
            <td>{{{this}}}</td>
            {{/each}}
          </tr>
          {{/each}}
        </tbody>
      </table>
    </div>
  </fieldset>
  {{/if}}
  <div class='large-12 columns'>
    <br>
    {{#if role.elasticity_policies}}
    <table class="dataTable policies_table">
      {{> tabs/oneflow-templates-tab/utils/role-tab/elasticity-thead}}
      <tbody>
        {{#each role.elasticity_policies}}
        <tr>
          <td>{{type}}</td>
          <td>{{adjust}}</td>
          <td>{{valOrDefault min_adjust_step "-"}}</td>
          <td>{{valOrDefault expression_evaluated this.expression}}</td>
          <td>
            {{#if period_number}}
            {{#if ../../servicePanel}}
            {{valOrDefault true_evals "0"}}/{{period_number}}
            {{else}}
            {{period_number}}
            {{/if}}
            {{else}}
            -
            {{/if}}
          </td>
          <td>{{valOrDefault period "-"}}</td>
          <td>{{valOrDefault cooldown "-"}}</td>
        </tr>
        {{/each}}
      </tbody>
    </table>
    {{/if}}
    <br>
    {{#if role.scheduled_policies}}
    <table class="dataTable policies_table">
      {{> tabs/oneflow-templates-tab/utils/role-tab/sched-thead}}
      <tbody>
        {{#each role.scheduled_policies}}
        <tr>
          <td>{{type}}</td>
          <td>{{adjust}}</td>
          <td>{{valOrDefault min_adjust_step "-"}}</td>
          {{#if start_time}}
          <td>{{tr "Start time"}}</td>
          <td>{{start_time}}</td>
          {{else}}
          {{#if recurrence}}
          <td>{{tr "Recurrence"}}</td>
          <td>{{recurrence}}</td>
          {{/if}}
          {{/if}}
        </tr>
        {{/each}}
      </tbody>
    </table>
    {{/if}}
  </div>
</form>
